---
version: '2'

services:

{% for orderer in orderers %}
  {{ orderer.name }}:
    container_name: {{ orderer.name }}
    image: hyperledger/fabric-orderer:{{ thetag }}
    network_mode: bridge
    hostname: {{ orderer.name }}
    environment:
      - ORDERER_GENERAL_LOGLEVEL=debug
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block/genesis.block
      - ORDERER_GENERAL_LOCALMSPID={{ orderer.org }}
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      - ORDERER_GENERAL_TLS_ENABLED={{ fabric.tls | lower }}
{% if fabric.tls %}
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
{% endif %}
      - ORDERER_GENERAL_TLS_CLIENTAUTHENABLED=false
      - ORDERER_KAFKA_RETRY_SHORTINTERVAL=1s
      - ORDERER_KAFKA_RETRY_SHORTTOTAL=30s
      - ORDERER_KAFKA_VERBOSE=true
    volumes:
      - {{ fabricworkdir }}/run/keyfiles:/var/hyperledger/orderer/orderer.genesis.block
      - {{ fabricworkdir }}/run/keyfiles/{{ orderer.org }}/orderers/{{ orderer.name }}.{{ orderer.org }}:/var/hyperledger/orderer
      - {{ fabricworkdir }}/run/keyfiles:/var/hyperledger/allorgs
    command: orderer

{% endfor %}

